﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Day02NightInterface
{
    public class Triangle:ICalculate
    {
        /// <summary>
        /// 三角形高，可以删除
        /// </summary>
        public float TriangleA
        {
            get;
            set;
        }
        /// <summary>
        /// 三角形底，可以删除
        /// </summary>
        public float TriangleH
        {
            get;
            set;
        }

        public float SideLength1
        {
            get;
            set;
        }
        public float SideLength2
        {
            get;
            set;
        }
        public float SideLength3
        {
            get;
            set;
        }


        public float CalculateArea()
        {
            //return 0.5f * TriangleA * TriangleH;
            float p = CalculatePerimeter() / 2;
            return (float)Math.Sqrt(p * (p - SideLength1) * (p - SideLength2) * (p - SideLength3));//海伦公式
        }

        public float CalculatePerimeter()
        {
            return SideLength1 + SideLength2 + SideLength3;
        }
    }
}